fix: Apply required overrides from allOf schemas#1384
Merged
dbanty merged 4 commits intoopenapi-generators:mainfrom Jan 10, 2026
Merged
fix: Apply required overrides from allOf schemas#1384dbanty merged 4 commits intoopenapi-generators:mainfrom
dbanty merged 4 commits intoopenapi-generators:mainfrom
Conversation
When using allOf with a reference to a base schema and then marking fields as required in a second schema, those fields are now correctly generated as required in the derived class. Properties inherited from referenced models are now updated to reflect required field overrides from the containing schema after all allOf schemas and their required fields are collected.
Add test_allof_required_override to verify that properties inherited from a base schema via allOf can be correctly marked as required in the derived schema's required list.
Add AllOfRequiredBase and AllOfRequiredDerived schemas to baseline specs to verify the generated code correctly handles required field overrides in allOf schemas. Update golden records accordingly.
dbanty
approved these changes
Jan 10, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes an issue where
requiredfield overrides inallOfschemas were being ignored when the base schema was referenced. Properties inherited from a base schema can now be correctly marked as required in derived schemas.Problem
When using
allOfwith a reference to a base schema and then marking fields as required in a second schema, the generator was ignoring the required override. For example:New behavior
A field will be
requiredif it was markedrequiredin the base schema or the derived schema. There is no way to remove arequiredrestriction in a derived schema. This is because for a message to be valid under anallOf, it must be valid under all of the parent schemas.